import {  Provide } from '@midwayjs/decorator';
import { BaseService } from '@cool-midway/core';
import { InjectEntityModel } from '@midwayjs/orm';
import { Repository } from 'typeorm';
import { WeiboTagsEntity } from '../entity/tags';

/**
 * 商品
 */
@Provide()
export class WeiboTagsService extends BaseService {
  @InjectEntityModel(WeiboTagsEntity)
  weiboTagsEntity: Repository<WeiboTagsEntity>;

  /**
   * 热点
   * @returns
   */
  async hot(offset: number, limit: number) {
    return this.weiboTagsEntity
      .createQueryBuilder('a')
      .select('a.*')
      .groupBy('a.name,a.num,a.id')
      .orderBy('a.num', 'DESC')
      .offset(offset)
      .limit(limit)
      .getRawMany();
  }

  async findInIds(ids) {
    return this.weiboTagsEntity.findByIds(ids);
  }
}
